<?php
/**
 * Tools for self-testing
 *
 * @author chedim
 */
abstract class aSelfTest
{
    public final function run()
    {
        $methods = get_class_methods($this);
        for($i = 0; $i < count($methods); $i++) {
            $method = $methods[$i];
            if(strpos($method, 'test_')===0) {
                $this->$method();
            }
        }
    }

    protected final function check_true($value)
    {
        if (!(bool)$value)
        {
            throw new eNotTrue();
        }
    }

    protected final function check_false($value)
    {
        if ((bool)$value)
        {
            throw new eNotFalse();
        }
    }

    protected final function check_equals($value, $model)
    {
        if ($value != $model)
        {
            throw new eNotEquals();
        }
    }

    protected final function check_not_equals($value, $model)
    {
        if ($value == $model)
        {
            throw new eEquals();
        }
    }

}
?>
